package com.ruoyi.PersonalPayments.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.PersonalPayments.domain.PersonalPayments;
import com.ruoyi.PersonalPayments.service.IPersonalPaymentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人电费信息Controller
 * 
 * @author 智电未来
 * @date 2024-07-12
 */
@RestController
@RequestMapping("/PersonalPayments/PersonalPayments")
public class PersonalPaymentsController extends BaseController
{
    @Autowired
    private IPersonalPaymentsService personalPaymentsService;

    /**
     * 查询个人电费信息列表
     */
    @PreAuthorize("@ss.hasPermi('PersonalPayments:PersonalPayments:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonalPayments personalPayments)
    {
        startPage();
        List<PersonalPayments> list = personalPaymentsService.selectPersonalPaymentsList(personalPayments);
        return getDataTable(list);
    }

    /**
     * 导出个人电费信息列表
     */
    @PreAuthorize("@ss.hasPermi('PersonalPayments:PersonalPayments:export')")
    @Log(title = "个人电费信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PersonalPayments personalPayments)
    {
        List<PersonalPayments> list = personalPaymentsService.selectPersonalPaymentsList(personalPayments);
        ExcelUtil<PersonalPayments> util = new ExcelUtil<PersonalPayments>(PersonalPayments.class);
        util.exportExcel(response, list, "个人电费信息数据");
    }

    /**
     * 获取个人电费信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('PersonalPayments:PersonalPayments:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(personalPaymentsService.selectPersonalPaymentsById(id));
    }

    /**
     * 新增个人电费信息
     */
    @PreAuthorize("@ss.hasPermi('PersonalPayments:PersonalPayments:add')")
    @Log(title = "个人电费信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonalPayments personalPayments)
    {
        return toAjax(personalPaymentsService.insertPersonalPayments(personalPayments));
    }

    /**
     * 修改个人电费信息
     */
    @PreAuthorize("@ss.hasPermi('PersonalPayments:PersonalPayments:edit')")
    @Log(title = "个人电费信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonalPayments personalPayments)
    {
        return toAjax(personalPaymentsService.updatePersonalPayments(personalPayments));
    }

    /**
     * 删除个人电费信息
     */
    @PreAuthorize("@ss.hasPermi('PersonalPayments:PersonalPayments:remove')")
    @Log(title = "个人电费信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(personalPaymentsService.deletePersonalPaymentsByIds(ids));
    }
}
